<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // function fn() {
        //     var num = 10;
        //     return function fun() {
        //         console.log(num);
        //     };
        // }
        // //fn外面的作用域访问fn（）内部的局部变量
        // fn()();

        function fn() {
            var num = 3;
            return function () {
                var n = 0;
                console.log(++n);
                console.log(++num);
            }
        }
        var f1 = fn();
        f1();//1 4
        f1();//1 5

        fn()();// 1 4
        fn()();//1 4
    </script>
</body>

</html>